{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "t1 = ()                 # 创建一个空元组\n",
    "t2 = (11,22,33)         # 创建一个包含三个元素的元组\n",
    "t3 = tuple([1,2,3,4])   # 使用列表创建元组\n",
    "t4 = tuple(\"abc\")       # 使用字符串创建元组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "tuple1 = (1,2,3,4,5)\n",
    "tuple2 = tuple(\"yuanzu\")\n",
    "sum = sum(tuple1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "dict1 = {\n",
    "  'name':'xbmu',\n",
    "  'location':'lanzhou'\n",
    "}\n",
    "\n",
    "dict2 = dict([('sape', 4139), ('guido', 4127), ('jack', 4098)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "dict2.clear()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4098"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dict2 = dict([('sape', 4139), ('guido', 4127), ('jack', 4098)])\n",
    "dict2.pop('jack')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "dict2['jack-again'] = 'dict'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "dict2['jack-again'] = 'dict-again'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_keys"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "books = dict([('title', 'Python 入门'), ('author', 'jack'), ('price', 68)])\n",
    "type(books.keys())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "中老年\n"
     ]
    }
   ],
   "source": [
    "age = 45\n",
    "if age>=18:\n",
    "  if age <35:\n",
    "    print('青年')\n",
    "  else:\n",
    "    print('中老年')\n",
    "else:\n",
    "  print('未成年')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "不正常\n"
     ]
    }
   ],
   "source": [
    "bmi = int(input('请输入bmi值'))\n",
    "\n",
    "if bmi>=23:\n",
    "  print('不正常')\n",
    "else:\n",
    "  print('正常')"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "11f1dc213e07634baa4c5c321dec03c05dafae643c50f20e6d1a492290c05dc2"
  },
  "kernelspec": {
   "display_name": "Python 3.9.7 64-bit",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
